<template>
  <div>
    <Table :columns="columns1" :data="data1"></Table>
    <Add v-model="isOpenAddPage" :UploadLkyDocumentTableManage="uploadLkyDocumentTableManage" />
    <FillInstruction v-model="isOpenInstruction"  />
    <div style="margin-top: 20px;">
      <Button type="primary" @click="openInstruction" >预览填写说明</Button>
    </div>

  </div>

</template>
<script>
import { queryStudentFillTableRecord } from '@/api/lky/lkyTableStorage'
import { createFormObj, getToken } from '@/libs/util'

import Add from './add.vue'
import FillInstruction from './fillInstruction.vue'
export default {
  components: {
    Add,
    FillInstruction
  },
  data () {
    return {
      columns1: [{
        title: '表名',
        key: 'file_name'
      },
      {
        title: '需填次数',
        key: 'times'
      },
      {
        title: '通过次数',
        key: 'times1'
      },
      {
        title: '开始时间',
        key: 'start_time'
      },
      {
        title: '结束时间',
        key: 'end_time'
      },
      {
        title: '操作',
        key: 'action',
        width: 250,
        align: 'center',
        render: (h, params) => {
          return h('div', [
            h(
              'Button',
              {
                props: {
                  size: 'small'
                },
                style: {
                  marginRight: '5px'
                },
                on: {
                  click: () => {
                    this.$router.push({
                      path: '/onlineView/onlineRoutePage',
                      query: {
                        newFileName: params.row.file_name
                      }
                    })
                  }
                }
              },
              '预览'
            ),
            h(
              'Button',
              {
                props: {
                  type: 'primary',
                  size: 'small'
                },
                style: {
                  marginRight: '5px'
                },
                on: {
                  click: () => {
                    window.location.href = '/admin/SoJpt/file/download?fileName=' + params.row.file_name
                  }
                }
              },
              '下载'
            ),
            h(
              'Button',
              {
                props: {
                  type: 'error',
                  size: 'small',
					  disabled: (params.row.times1 >= params.row.times)
                },
                on: {
                  click: () => {
                    this.uploadLkyDocumentTableManage = params.row
                    this.handleOpenPage('upload')
                  }
                }
              },
              '上传'
            )
          ])
        }
      }
      ],
      data1: [
      ],
      isOpenAddPage: false,
      uploadLkyDocumentTableManage: null,
      isOpenInstruction: false
    }
  },
  methods: {
    openInstruction () {
      this.$router.push({
        path: '/onlineView/onlineRoutePage',
        query: {
          newFileName: '学生实习表填写说明.doc'
        }
		  })
      // window.location.href='/SoJpt/file/download?fileName=' + '学生实习表填写说明.doc'
    },
    handleOpenPage (name) {
      // 打开页面事件(添加页,编辑页...)
      if (name == 'upload') this.isOpenAddPage = true
    }
  },
  mounted () {
    queryStudentFillTableRecord({
      uid: getToken()
    }).then(res => {
      console.log(res)
      this.data1 = res.data
    }).catch(err => {
      this.$Message.error(err)
    })
  }
}
</script>
